<html>
<head><meta charset="utf-8"><title>naked fn codegen · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html">naked fn codegen</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="202993471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/naked%20fn%20codegen/near/202993471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathaniel McCallum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html#202993471">(Jul 06 2020 at 14:02)</a>:</h4>
<p>I'm trying to take a stab at fixing <a href="https://github.com/rust-lang/rust/issues/42779">https://github.com/rust-lang/rust/issues/42779</a> by suppressing debug output for the naked fn's parameters.</p>



<a name="202993560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/naked%20fn%20codegen/near/202993560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathaniel McCallum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html#202993560">(Jul 06 2020 at 14:03)</a>:</h4>
<p>I figure I could do it a couple of places.</p>



<a name="202993565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/naked%20fn%20codegen/near/202993565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathaniel McCallum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html#202993565">(Jul 06 2020 at 14:03)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs#L16-L42">https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs#L16-L42</a></p>



<a name="202993714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/naked%20fn%20codegen/near/202993714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathaniel McCallum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html#202993714">(Jul 06 2020 at 14:04)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/librustc_mir_build/build/mod.rs#L793-L809">https://github.com/rust-lang/rust/blob/master/src/librustc_mir_build/build/mod.rs#L793-L809</a></p>



<a name="202993785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/naked%20fn%20codegen/near/202993785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathaniel McCallum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html#202993785">(Jul 06 2020 at 14:05)</a>:</h4>
<p>I think the first one is probably the most reasonable since we don't know how other backends will behave.</p>



<a name="202993847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/naked%20fn%20codegen/near/202993847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathaniel McCallum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html#202993847">(Jul 06 2020 at 14:06)</a>:</h4>
<p>I can't figure out, however, how to get the function definition in that scope so that I can inspect its attributes.</p>



<a name="202993881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/naked%20fn%20codegen/near/202993881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathaniel McCallum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html#202993881">(Jul 06 2020 at 14:06)</a>:</h4>
<p>Help?</p>



<a name="202994725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/naked%20fn%20codegen/near/202994725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html#202994725">(Jul 06 2020 at 14:13)</a>:</h4>
<p>tcx.codegen_fn_attrs</p>



<a name="203007816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/naked%20fn%20codegen/near/203007816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathaniel McCallum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html#203007816">(Jul 06 2020 at 16:02)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> I'm not seeing that. What am I missing?</p>



<a name="203008886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/naked%20fn%20codegen/near/203008886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html#203008886">(Jul 06 2020 at 16:10)</a>:</h4>
<p><span class="user-mention" data-user-id="319062">@Nathaniel McCallum</span> <code>self.hir.tcx().codegen_fn_attrs(fn_def_id)</code> returns a <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/middle/codegen_fn_attrs/struct.CodegenFnAttrs.html"><code>CodegenFnAttrs</code></a>, which has a <code>flags</code> field which has a <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/middle/codegen_fn_attrs/struct.CodegenFnAttrFlags.html#associatedconstant.NAKED"><code>CodegenFnAttrFlags::NAKED</code></a> flag.</p>



<a name="203008920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/naked%20fn%20codegen/near/203008920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathaniel McCallum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html#203008920">(Jul 06 2020 at 16:10)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> Awesome, thanks!</p>



<a name="203030266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/naked%20fn%20codegen/near/203030266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nathaniel McCallum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html#203030266">(Jul 06 2020 at 19:25)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> Thanks for the help. It was exactly what I needed! <a href="https://github.com/rust-lang/rust/pull/74105">https://github.com/rust-lang/rust/pull/74105</a></p>



<a name="203380432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/naked%20fn%20codegen/near/203380432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/naked.20fn.20codegen.html#203380432">(Jul 09 2020 at 12:44)</a>:</h4>
<p>We shouldn't be emitting any alloca calls at all in naked functions. They cause incorrect codegen in debug builds.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>